package mspbots.cw.client.core.data.companies;

import com.fasterxml.jackson.databind.JsonNode;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import mspbots.cw.common.QueryParams;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import javax.validation.Valid;

/**
 * @author Jay.Yang
 */
@Log4j2
@RestController
@RequiredArgsConstructor
@RequestMapping("configurations/{tenantId}")
public class ConfigurationsController {

    private final ConfigurationsServiceImpl configurationsService;

    @GetMapping("find")
    public Flux<JsonNode> find(@PathVariable Long tenantId, @Valid QueryParams queryParams) {
        return this.configurationsService.find(tenantId, queryParams);
    }

    @GetMapping("count")
    public Mono<JsonNode> count(@PathVariable Long tenantId, @Valid QueryParams queryParams) {
        return this.configurationsService.count(tenantId, queryParams);
    }

}
